﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project3
{
    public partial class CustomerOrderDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    GridOrderDetailCustomer.DataSourceID = "";
            //    GridOrderDetailCustomer.DataSource = GetCustomerOrderDetail();
            //    GridOrderDetailCustomer.DataBind();
            //}
        }

        protected void SearchButton_Click(object sender, EventArgs e)
        {
            var tableAdapter = new CustomerOrderDetailsDataSetTableAdapters.DataTable1TableAdapter();
            RepeaterSearch.DataSource = tableAdapter.GetDataByParam("%" + ParameterText.Text + "%");
            RepeaterSearch.DataBind();
            GridView1.Visible = false;
        }

        public CustomerOrderDetailsDataSet.DataTable1DataTable GetCustomerOrderDetail()
        {
            var tableAdapter = new CustomerOrderDetailsDataSetTableAdapters.DataTable1TableAdapter();
            return tableAdapter.GetData();
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                SqlDataSource s = (SqlDataSource)e.Row.FindControl("SqlDataSource2");
                s.SelectParameters[0].DefaultValue = e.Row.Cells[0].Text;
                //s.SelectParameters[1].DefaultValue = e.Row.Cells[0].Text;
            }
        }

        protected void ResetButton_Click(object sender, EventArgs e)
        {
            RepeaterSearch.Visible = false;
            GridView1.Visible = true;
        }
    }
}